
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>跑马灯</title>
    <script type="text/javascript">
        onload = function () {
            var txt = document.getElementById("txt");
            var txt2 = txt.innerHTML.trim();
            // alert(txt.innerHTML.trim().charAt(0));
            //alert(txt.innerHTML.trim().substr(0,2));
            //函数放在前面！！
            var paoMaDeng = function () {　　　　　　　　//两个获取字符的方法，charAt(0)和substr(0,1)
                var first = txt2.charAt(0);
                var rest = txt2.substr(1);
                txt2 = rest + first;
                txt.innerHTML = txt2;

            }　　　　　　　　//调用放在后面！！！
            aaa = setInterval(paoMaDeng, 100);
        }


    </script>
</head>
<body>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img class="d-block w-100" src="image1.jpg" alt="First slide">
        </div>
        <div class="carousel-item">
            <img class="d-block w-100" src="image2.jpg" alt="Second slide">
        </div>
        <div class="carousel-item">
            <img class="d-block w-100" src="image3.jpg" alt="Third slide">
        </div>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
</body>
</html>